home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: undergrad.math.uwaterloo.ca!sckettle
- From: sckettle@undergrad.math.uwaterloo.ca (Steve Kettle)
- Subject: Re: delete
- Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
- Message-ID: <DMFBFn.nIC@undergrad.math.uwaterloo.ca>
- Date: Wed, 7 Feb 1996 20:54:59 GMT
- References: <DMDBqB.Bw5@undergrad.math.uwaterloo.ca> <31185EBB.41C67EA6@intellektik.informatik.th-darmstadt.de>
- Nntp-Posting-Host: noether.math.uwaterloo.ca
- Organization: University of Waterloo
-
- In article <31185EBB.41C67EA6@intellektik.informatik.th-darmstadt.de>,
- Enno Sandner <enno@intellektik.informatik.th-darmstadt.de> wrote:
- >Steve Kettle wrote:
- >>
- >> The delete operator can be overloaded in a class by overloading with
- >> declaration
- >> void operator delete(void*);
- >>
- >> There is no way I see to set a pointer being deleted to 0 because of the
- >> pass by value.
- >>
- >> Is there anyway to force a deleted pointer to be zero or are we just
- >> at mercy of the compiler implementation?
- >> --
- >
- >I don't know of any compiler that zeros the pointer-value when the
- >underlying object is deleted. Anyway unless you get completly rid of
- >ordinary pointers and replace them by wrappers there is no reasonable
- >way to mark an object as deleted. The remaining problem will always be
- >objects that are referred by more then one pointer.
- >
- > Enno
-
- I don't know of any compiler which zeros the pointer either despite
- what it says in the ARM:
-
- 'Implementing the delete operator to modify the value of a
- deleted pointer can be useful for debugging by ensuring that a pointer
- cannot be successfully used after being deleted.'
-
- Zeroing the pointer does not solve the multiple pointer to same
- thing problem but at least it stops some dormant run time errors. I
- guess passing the deleted pointer by reference ( if it were allowed )
- would be a bad idea because of temporary creation :
- eg:
-
- struct A{};
- A a;
- delete &a; // ( temp pointer would be created here )
-
- However I don't see any other problems with this idea.
-
-
-
- --
-